0.1 Background

There are an ever increasing number of animated, or interactive, graphical libraries for R. Choosing which library to use, and which library will be persistent and stable over time is a challenge.

plotly is a JavaScript graphing library that creates graphics for the web.

plotly for R is one of the easiest, and most richly featured libraries to use for creating graphics on the web.

0.2 The Best Place to Start With Plotly Is ggplotly()

0.3 Construct a Simple ggplot

Remember all ggplots start simple, and then are tweaked…

0.4 Construct a More Complicated ggplot

0.5 plotly-etize it

Mouse over the plot to see the interactivity.

0.6 Piping

Pipes %>% connect pieces of a command e.g. data to a graph command.

0.7 Use dplyr to remove “Aggregates”

0.8 Use plotly syntax

Plotly Has Similar Logic to ggplot.

0.9 3D Scatterplot

plotly does not have every geometry that ggplot2 has, and vice versa.

Most notably, a smoother geometry seems to be missing.

Note also, the cryptic (to me) use of (embedded) lists to style the graph.

0.10 A 3D Graph!

0.11 Let’s Think About the Idea of Dimension

On the previous 3D graphs, we had 3 dimensions of GDP, life expectancy and Gini coefficient of inequality.

Do the preceding 3D graph, or the 2D graph on the next slide do a better job of representing multiple dimensions? What are the best ways of representing additional dimensions of data?

0.12 A 2D Version With Some of the Same Style Elements

0.13 A Bar Graph!

Because plotly does not have some features of ggplot, we need to use dplyr to manage our data (summarize scores) before sending to plotly.

0.14 A Map!!

plotly relies on ISO standard codes for country names in order to make maps. plotly can also use State abbreviations, and latitudes and longitudes.

0.15 A Globe!!!

0.16 Questions?

0.17 Explore!!!

https://plot.ly/r/